package ro.gateway.aida.struts.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import ro.gateway.aida.utils.HttpUtils;



/**
 * <p>Title: Romanian AIDA</p>
 * <p>Description: </p>
 * <p>Copyright: Copyright (comparator) 2003</p>
 * <p>Company: ro-gateway</p>
 * @author Mihai Popoaei, mihai_popoaei@yahoo.com, smike@intellisource.ro
 * @version 1.0-* @version $Id: ForwarderAction.java,v 1.1 2004/10/24 23:37:03 mihaipostelnicu Exp $
 */
public class ForwarderAction extends Action
{
      public ActionForward execute(
            ActionMapping mapping,
            ActionForm form,
            HttpServletRequest request,
            HttpServletResponse response )
            throws Exception
      {
            String forward_name = HttpUtils.getValidTrimedString(request, "fw", null);

            if (forward_name != null) {
			  ActionForward fw = mapping.findForward(forward_name);
			  if (fw != null) {
				  return fw;
			  } else {
				  System.err.println("Forward " + fw + " not found.");
			  }
            }

            return mapping.getInputForward();
      }
}
